<?php

namespace Home\Model;
use Think\Model\RelationModel;

class RoleModel extends RelationModel {

    protected $tableName = 'role';
    protected $pk = 'Id';
    protected $_link = array(
        'User'=>array(
            'mapping_type'      =>  self::MANY_TO_MANY,
            'class_name'        =>  'User',
            'mapping_name'      =>  'users',
            'foreign_key'       =>  'uid',
            'relation_foreign_key'  =>  'rid',
            'relation_table'    =>  'role_user' //此处应显式定义中间表名称，且不能使用C函数读取表前缀
            )
        );
}